﻿using System;
using System.Text;

namespace MRMDS.Utils
{
    public static class Logger
    {
        private static string path = "\\log.txt";
        private static FileStream? writer;

        static Logger()
        {
            path = Directory.GetCurrentDirectory() + path;
            writer = File.OpenWrite(path);
        }

        public static void Write(string message)
        {
            if (writer != null)
            {
                writer.Write(UTF8Encoding.UTF8.GetBytes($"[{DateTime.Now.ToString()}]:{message}\r\n"));
            }
        }
        public static void Close()
        {
            if (writer != null)
            {
                writer.Flush();
                writer.Dispose();
            }
        }
    }
}
